﻿using BLL;
using EntityCor.DapperExtensions;
using HY.DataAccess;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Dapper;
using EntityCor;
using Entity;

namespace MySqlTest
{
    public partial class About : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //var myConnectionString = ConfigurationManager.ConnectionStrings["MySqlServer"].ConnectionString;
            //MySqlConnection mycn = new MySqlConnection(myConnectionString);
            try
            {
                //mycn.Open();
                

                //var cityResult = mycn.Query<city>("select * from city").ToList();
                //var count = cityResult.Count;


                //var cityEntity = new city
                //{
                //    Name = "chengdu",
                //    CountryCode = "CN",
                //    District = "Test",
                //    Population = 1000

                //};
                //mycn.Insert<city>(cityEntity,null,null,DatabaseType.MySql);
                //Response.Write("数据库已连接");

                //var testUser = mycn.Query<tb_user>("select * from tb_user");
                //var count = testUser.Count();

                //IList<IPredicate> predList=new List<IPredicate>();
                //predList.Add(Predicates.Field<tb_user>(p=>p.tb_userAge,Operator.Ge,26));
                //predList.Add(Predicates.Field<tb_user>(p=>p.tb_userName,Operator.Like,"yi%"));
                //var predicateGroup = Predicates.Group(GroupOperator.And, predList.ToArray());

                //IPredicateGroup  predicateGroup=new PredicateGroup();
                //predicateGroup.Predicates = predList;

                
                //var testUserList = mycn.GetList<tb_user>(predicateGroup, null, null, null, false, DatabaseType.MySql);
                //var userCount = testUserList.Count();

                //var tbuser = new tb_user();
                //tbuser.tb_userAge = 26;
                //tbuser.tb_userName = "test";
                //var res = mycn.Insert<tb_user>(tbuser, null, null, DatabaseType.MySql);

                var userbll = new tb_userBll();
                var users = userbll.GeTbUsers();

            }
            catch (Exception ex)
            {
                //Response.Write("连接失败");
            }
        }
    }
}